﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebBanThuoc.DAO;
using WebBanThuoc.DTO;
using WebBanThuoc.Server;

namespace WebBanThuoc
{
    public partial class ShowTinTuc : System.Web.UI.Page
    {
        IServerWeb sw = new ServerWeb();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) loadData();
            this.LoadComplete += new EventHandler(ShowTinTuc_LoadComplete);
        }
        void ShowTinTuc_LoadComplete(object sender, EventArgs e)
        {
            sw.closeConnection();
        }
        public void loadData()
         {
            int trang = 1;
            if (Request.QueryString["trang"] != null)
            {
                trang = Convert.ToInt32(Request.QueryString["trang"]);
            }
            int soTinTrenTrang = int.Parse(System.Configuration.ConfigurationManager.AppSettings["pageSize_TinTuc"]); //6;
            int MaDanhMuc = Convert.ToInt32(Request.Params["MaDanhMuc"]);  
            TinTuc_DAO daoTT = new TinTuc_DAO(sw.Connection);
            List<TinTuc> listTT = daoTT.getList_Paging_DM(MaDanhMuc, trang, soTinTrenTrang);
            int tt_tongSoTrang = daoTT.totalNumberOfPages_All(MaDanhMuc, soTinTrenTrang);
            Session.Add("listTT",listTT);
            Session.Add("tt_tongSoTrang", tt_tongSoTrang);
            
        }
    }
}